package com.gu.mobileweb.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.gu.mobileweb.config.PageResult;
import com.gu.mobileweb.model.IndexEatBottom;
import com.gu.mobileweb.mapper.IndexEatBottomMapper;
import com.gu.mobileweb.service.IndexEatBottomService;
import org.apache.commons.collections.MapUtils;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Service;

import java.util.Map;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author GSQ
 * @since 2020-12-07
 */
@Service
public class IndexEatBottomServiceImpl extends ServiceImpl<IndexEatBottomMapper, IndexEatBottom> implements IndexEatBottomService {

    @Override
    public PageResult<IndexEatBottom> allList(Map<Object, String> params) {
        Page<IndexEatBottom> page = new Page<>(MapUtils.getInteger(params,"currentPage"),MapUtils.getInteger(params, "pageSize"));
        QueryWrapper wrapper = new QueryWrapper();
        if (params.get("ebName") != null && StringUtils.isNotBlank(params.get("ebName").toString())) {
            wrapper.eq("eb_name", params.get("ebName").toString());
        }
        page = baseMapper.selectPage(page, wrapper);
        return PageResult.<IndexEatBottom>builder().records(page.getRecords()).code(0).total(page.getTotal()).build();
    }
}
